package com.quanyan.ic.datacenter.http.controller;

import com.quanyan.ic.common.http.APIResponse;
import com.quanyan.ic.common.http.enums.ApiResponseEnum;
import com.quanyan.ic.datacenter.http.req.ReqReport;
import com.quanyan.ic.datacenter.http.service.AlarmsDayReportService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by Administrator on 2017/8/21.
 */
@RestController
@RequestMapping("/larkic/icData/report/")
public class AlarmsReportController {

    private static final Logger logger = LoggerFactory.getLogger(AlarmsReportController.class);

    @Autowired
    private AlarmsDayReportService alarmsDayReportService;

    //全国概括表格
    @RequestMapping("allCityTable")
    public APIResponse queryCityTable(@RequestBody ReqReport reqReport) {
        try {
            reqReport.getEndDateStr();
            reqReport.getStartDateStr();
            return APIResponse.returnSuccess(alarmsDayReportService.allAlarmsTable(reqReport));
        } catch (Exception e) {
            logger.error("{}", e);
            return APIResponse.returnFail(ApiResponseEnum.INTERNAL_ERROR);
        }
    }


    //折现图
    @RequestMapping("cityLineChart")
    public APIResponse queryCityDayReport(@RequestBody ReqReport reqReport) {
        try {
            return APIResponse.returnSuccess(alarmsDayReportService.cityTimePointLineChartPie(reqReport));
        } catch (Exception e) {
            logger.error("{}", e);
            return APIResponse.returnFail(ApiResponseEnum.INTERNAL_ERROR);
        }
    }


}
